using System;
using Castle.ActiveRecord;
using System.Collections.Generic;

namespace IronMis2.Models
{
    [ActiveRecord("check")]
    public class Check:ActiveRecordBase<Check>
    {
        private Guid id;
        private string checkId;
        private DateTime? chDate;
        private Storehouse storeHouse;
        private Employee employee;
        private IList<CommodityRecord> items;

        [PrimaryKey(PrimaryKeyType.GuidComb,Column = "id")]
        public Guid Id
        {
            set { id = value; }
            get { return id; }
        }

        [Property(Column = "check_id", SqlType = "char",Length = 10)]
        public string CheckId
        {
            set { checkId = value; }
            get { return checkId; }
        }

        [Property(Column = "ch_date",SqlType = "datetime",Length = 8)]
        public DateTime? ChDate
        {
            set { chDate = value; }
            get { return chDate; }
        }

        [BelongsTo(Column = "stor_id",ForeignKey = "id",Insert = true,Update = true,Fetch = FetchEnum.Select)]
        public Storehouse StoreHouse
        {
            set { storeHouse = value; }
            get { return storeHouse; }
        }

        [BelongsTo(Column = "s_number",ForeignKey = "id",Insert = true,Update = true,Fetch = FetchEnum.Select)]
        public Employee Employee
        {
            set { employee = value; }
            get { return employee; }
        }

        [HasMany(Lazy = true, Inverse = true, Cascade = ManyRelationCascadeEnum.All)]
        public IList<CommodityRecord> Items
        {
            set { items = value; }
            get { return items; }
        }
    }
}
